﻿using Model;
using Model.DTO;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BLL.Interface
{
    /// <summary>
    /// 基础LL接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBaseBLL<T> where T : class, new()
    {
        /// <summary>
        /// 数据上下文
        /// </summary>
        /// <returns></returns>
        MyDbContext DbContext();
        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        Task<bool> Add(T entity);
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        Task<bool> Delete(int id);
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        Task<bool> Update(T entity);
        /// <summary>
        /// 查询一个，通过id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> Find(int id);
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <returns></returns>
        Task<DataList<T>> List();
        /// <summary>
        /// 查询列表，少量的数据，默认5条
        /// </summary>
        /// <param name="limit">限制</param>
        /// <returns></returns>
        Task<List<T>> List(int limit = 5);
        /// <summary>
        /// 查询列表，通过id列表
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        Task<List<T>> List(List<int> ids);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="limit">限制</param>
        /// <returns></returns>
        Task<DataList<T>> Pagination(Limit limit);
    }
}
